amelog ("Initing maps' interface ...")

if (type(server) == "nil") then
	server = { }
end

if (type(server.maps) == "nil") then
	server.maps = { }
end

map_register = function (map, map_id, map_name)
	amelog ("Initing LUA for map " .. map_name .. " (" .. map_id .. ")")
	server.maps[map_id] = { p=map, name=map_name, id=map_id, npcs={}, mobs={} }
	amelog("New id is : " .. server.maps[map_id].id )
	return server.maps[map_id]
end

map_register_npc = function (map_id, name, x, y, looklikeid)
	id  = table.getn(server.maps[map_id].npcs)
	table.insert (server.maps[map_id].npcs, {
		hook = mapAddObject(map.p, x, y, 16, id, name), 
		name=name, 
		x=x, 
		y=y, 
		id=id,
		looklikeid=looklikeid
	})
end

map_register_mob = function (map_id, name, x, y, z, id, class)
	if type(server.maps[map_id].mobs[id]) == "table" then
		amelog("Warning: mob with this id already exists.")
		return 0
	end

	if type == "nil" then
		type = 2
	end
	
	server.maps[map_id].mobs[id] = { 
		hook = mapAddObject(map.p, x, y, 2, id, name), 
		name=name, 
		x=x, 
		y=y, 
		id=id, 
		z=z,
		class=class 
	}
	server.maps[map_id].highest_id = id 
	return 	server.maps[map_id].mobs[id]
end

amelog ("Finished initing interface...")